<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>查看订单</title>
    </head>
    <body>
        <br>
        <table width="100%" align="center" border="1" cellpadding="2" cellspacing="0">
            <tr>
                <td>
                    <table width="100%" align="center" border="0">
                        <tr bgcolor="#ffffec">
                            <td width="55%" height="35" align="left">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tbody>
                                        <tr>
                                            <td width="36" height="30" align="left" valign="top">
                                                <img height="30" hspace="3" src="/images/airways/<%=@airways.airways_code%>.gif" width="30" align="absmiddle" vspace="3" />
                                            </td>
                                            <td align="left">
                                                <strong><%=@airways.airways_name %>(<%=@airways.airways_code %>)</strong>
                                                　航班：<%=@weborder.air_no %> 　<a href="#">[机型：<%=@weborder.plane_type %>]</a>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                            <td width="20%" align="left">
                                票面价：360.0 元
                            </td>
                            <td width="25%" align="left">
                                订单编号：<%=@weborder.order_no %>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                　起飞地：<%=@from_airport.airport_name %>(<%=@from_airport.airport_code %>)<%=@weborder.fly_time %>
                                <br/>
                                　到达地：<%=@to_airport.airport_name %>(<%=@to_airport.airport_code %>)<%=@weborder.arr_time %>
                            </td>
                            <td width="45%">
                                预订日期：<%=@weborder.created_at.strftime("%Y-%m-%d %H:%M:%S") %>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br>
        <table width="100%" border="1" cellpadding="2" cellspacing="0">
            <tr>
                <td width="" align="center" nowrap="nowrap">
                    记录编号
                </td>
                <td width="" align="center" nowrap="nowrap">
                    舱位
                </td>
                <td width="" align="center" nowrap="nowrap">
                    机建/燃油税
                </td>
                <td width="" align="center" nowrap="nowrap">
                    起飞日期
                </td>
                <td width="" align="center" nowrap="nowrap">
                    支付方式
                </td>
                <td align="center" nowrap="nowrap">
                    订单总金额
                </td>
            </tr>
            <tr>
                <td align="center">
                    <%=@weborder.pnr %>&nbsp;
                </td>
                <td align="center">
                    <%=@weborder.position %>&nbsp;
                </td>
                <td align="center">
                    <%=@airdrome_tax %>/<%=@fuel_tax %>
                </td>
                <td align="center">
                    <%=@weborder.fly_date %>&nbsp;
                </td>
                <td align="center">
                    网上支付
                </td>
                <td align="center">
                    <font color="red">
                        <%=@weborder.price_sum %>&nbsp;
                    </font>
                </td>
            </tr>
            <tr>
                <td colspan="6">
                    <table width="100%" cellpadding="1" cellspacing="0">
                        <tr>
                            <td width="">
                                出票时间：<%if @weborder.ticket_out_date %>
                                <%=@weborder.ticket_out_date %>
                                <%else %>未出票<%end %>
                            </td>
                            <td width="" height="30" align="left">
                                订单状态：<span id="status_div"><%=@weborder.status %></span>&nbsp;
                            </td>
                            <td width="" height="30" align="left">
                                客户折扣率：<%=@weborder.rake_off %>&nbsp;
                            </td>
                            <td align="center" valign="middle">
                                <%if @weborder.status==Constants::WEB_ORDER_STATUS_DDZF %>
                                  <a href="/ticket/ready_pay?web_order_id=<%=@weborder.id%>&from_to=<%=@weborder.fromto%>" target="_blank">现在去支付</a>
                                <%end%>  
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table width="100%" border="0">
            <tr>
                <td align="center">
                    <%if @weborder.status==Constants::WEB_ORDER_STATUS_DDZF %>
                    <input name="cancelorder" type="button" onClick="cancelOrder(this)" value="取消订单"/><%end %>
                    <%if @weborder.trx_status==Constants::WEB_ORDER_STATUS_ZFCG %>
                    <input name="cancelorder" type="button" onClick="cancelOrder(this)" value="申请取消"/><%end %>
                    <input name="modorder" type="button" onClick="modifyOrder(this)" value="更改订单" />
                    <font color="red">
                        支付完成后取消订单,请联系客服,确认退款金额!
                    </font>
                    &nbsp;
                </td>
            </tr>
        </table>
        <br/>
        <div id="table_biaoti">
            登机人信息
        </div>
        <table width="100%" border="1" cellpadding="2" cellspacing="0">
            <tr>
                <td width="" align="center">
                    登机人
                </td>
                <td width="" align="center">
                    乘客类型
                </td>
                <td width="" align="center">
                    证件
                </td>
                <td width="" align="center">
                    证件号码
                </td>
                <td width="" align="center">
                    联系号码
                </td>
                <td width="" align="center">
                    票价
                </td>
                <td width="" align="center">
                    票号
                </td>
                <td width="" align="center">
                    操作
                </td>
                <td width="" align="center">
                    行程单
                </td>
            </tr>
            <%
            for ticket in @weborder.tickets
            %>
            <tr>
                <td align="center">
                    <%=ticket.pass_name %>&nbsp;
                </td>
                <td align="center">
                    成人&nbsp;
                </td>
                <td align="center">
                    身份证&nbsp;
                </td>
                <td align="center">
                    <%=ticket.pass_card_id %>&nbsp;
                </td>
                <td align="center">
                    <%=ticket.pass_tel %>&nbsp;
                </td>
                <td align="center">
                    <%=ticket.total_price %>&nbsp;
                </td>
                <td align="center">
                    <%=ticket.ticket_no %>&nbsp;
                </td>
                <td align="center" style="cursor:hand">
                    <a href="javascript:cancelTicket('<%=ticket.id%>')">取消</a>
                </td>
                <td align="center">
                    &nbsp;
                </td>
            </tr>
            <% end %>
        </table>
        <table width="100%" border="0">
            <tr>
                <td width="100%" align="right">
                    <font color="red">
                        如有申请取消中的机票,请联系客服,确认退款金额!
                    </font>
                </td>
            </tr>
        </table>
        <br/>
        联系人信息
        <table width="100%" cellpadding="2" cellspacing="0">
            <tr>
                <td width="16%" align="right">
                    联系人：
                </td>
                <td width="84%">
                    <%=@weborder.link_man %>&nbsp;
                </td>
            </tr>
            <tr>
                <td align="right">
                    手机：
                </td>
                <td>
                    <%=@weborder.link_tel %>&nbsp;
                </td>
            </tr>
            <tr>
                <td align="right">
                    Email：
                </td>
                <td>
                    <%=@weborder.link_email %>&nbsp;
                </td>
            </tr>
            <tr>
                <td align="right">
                    联系地址：
                </td>
                <td>
                    <%=@weborder.link_address %>&nbsp;
                </td>
            </tr>
        </table>
        <br/>
        <script>
            var id = "<%=@weborder.id%>";
            function cancelOrder(){
                Ext.MessageBox.confirm('确认提示', '您确定要取消该订单吗？', function(btn){
                    if (btn == 'yes') {
                        Ext.Ajax.request({
                            url: '/ticket/cancel_order',
                            params: 'id=' + id,
                            method: 'GET',
                            success: function(result, request){
                                var res = result.responseText;
                                if (result.responseText.indexOf("取消订单成功") >= 0) {
                                    Ext.MessageBox.alert('提示', '取消订单成功');
                                    var status = res.substring(res.indexOf(",") + 1);
                                    $('status_div').innerHTML = status;
                                }
                                else {
                                    if (res.indexOf(",") > 0) {
                                        var str = res.substring(0, res.indexOf(","));
                                        Ext.MessageBox.alert('操作信息', str);
                                    }
                                    else {
                                        Ext.MessageBox.alert('操作信息', result.responseText);
                                    }
                                }
                            },
                            failure: function(result, request){
                                Ext.MessageBox.alert('操作信息', '取消订单失败');
                            }
                        })
                    }
                })
            }
            
            function cancelTicket(tid){
                Ext.MessageBox.confirm('确认提示', '您确定要取消这张票吗？', function(btn){
                    if (btn == 'yes') {
                        //alert(tid);
                        Ext.Ajax.request({
                            url: '/ticket/cancel_ticket',
                            params: 'id=' + tid,
                            method: 'GET',
                            success: function(result, request){
                                var res = result.responseText;
                                if (result.responseText.indexOf("成功") >= 0) {
                                    Ext.MessageBox.alert('提示', '取消成功');
                                    
                                    var panel = tabs.getActiveTab();
                                    panel.getUpdater().update();
                                    
                                }
                                else {
                                    if (res.indexOf(",") > 0) {
                                        var str = res.substring(0, res.indexOf(","));
                                        Ext.MessageBox.alert('操作信息', str);
                                    }
                                    else {
                                        Ext.MessageBox.alert('操作信息', result.responseText);
                                    }
                                }
                            },
                            failure: function(result, request){
                                Ext.MessageBox.alert('操作信息', '取消订票信息失败');
                            }
                        })
                    }
                })
            }
            
            function modifyOrder(){
                
                var url = "/ticket/modify_order?id="+id;
                var panel = tabs.getActiveTab();
                panel.getUpdater().update(url);
                panel.setTitle('修改订单');
                
            }
        </script>
    </body>
</html>
